import Vue from 'vue';
import { ToastPlugin, LoadingPlugin, ConfirmPlugin, AlertPlugin, TransferDom } from 'vux';

import i18n from '@/common/i18n';
import logan from '@/common/logan';
import App from './App';
import Utils from './utils';
import store from './store';
import router from './router';
import infiniteScroll from 'vue-infinite-scroll';

import http from './utils/http';

Vue.config.productionTip = false;
Vue.config.devtools = true;

Vue.prototype.$eventBus = new Vue();

Vue.prototype.$http = http;

Vue.prototype.$logan = logan;

// FIXME(CFY) 使用 script js 引入
// import moment from 'moment';
// import 'moment/locale/zh-cn';
Vue.prototype.$moment = moment;

Vue.prototype.$vrv = vrv;

Vue.prototype.$utils = Utils;

import preview from 'vue-photo-preview';
import 'vue-photo-preview/dist/skin.css';
const options = { fullscreenEl: false, tapToClose: true };

Vue.use(preview, options);

Vue.use(ToastPlugin);
Vue.use(LoadingPlugin);
Vue.use(ConfirmPlugin);
Vue.use(AlertPlugin);
Vue.use(infiniteScroll);

Vue.directive('transfer-dom', TransferDom);

/* eslint-disable no-new */
const vue = new Vue({
  el: '#app',
  router,
  directives: { infiniteScroll },
  i18n,
  store,
  beforeMount() {
    window.$vueDelegate = this;
    window.$vuxDelegate = this.$vux;
  },
  render: h => h(App),
});

export default vue;
